<template>
	<view class="order-container">
		<!-- 个人信息 -->
		<view class="person-info">
			<!-- 收货人 -->
			<view class="consignee">
				收货人：xxx 151xxxxxxxx
			</view>
			<!-- 自提点 -->
			<view class="self-go">
				<text>自提点：xxxxxxx</text>
				<text></text>
			</view>
		</view>

		<!-- 商品数据列表 -->
		<view class="shop-list">
			<!--订单商品列表 -->
			<view class="cart-item" v-for="(item,index) in newCartList" :key="item.id">
				<!-- <view class="checkbox">
					<text class='iconfont icon-xuanzhong ' :class="{active: item.isSelected}"
						@click="changeSelected(!item.isSelected, index)"></text>
				</view> -->
				<image class="shop-img" :src="item.listPicUrl" mode=""></image>
				<view class="shop-info">
					<view class="text">
						{{item.name}}
					</view>
					<view class="price">
						{{item.retailPrice}}
					</view>
					<view class="number ">
						<text class="del" @click="onChange(false, index)"> - </text>
						<text class="count"> {{item.count}} </text>
						<text class="add" @click="onChange(true, index)"> + </text>
					</view>
				</view>

			</view>
		</view>
		<!-- 商品信息 -->
		<view class="shop-info">
			<view class="common ">
				<text>商品总额</text>
				<text class="all-price">{{totalPrice}}</text>

			</view>
			<view class="common ">
				<text>促销优惠</text>
				<text class="pub">促销与优惠卷不可同享</text>
			</view>
			<view class="common ">
				<text>品牌礼金</text>
				<text class="pub">暂无品牌礼金可用</text>
			</view>
			<view class="common ">
				<text>优惠券</text>
				<text class="pub">无</text>
			</view>

		</view>
		<!-- 订单备注 -->
		<view class="order-comment">
			<text>订单备注</text>
			<text class="pub">请输入</text>
		</view>
		<!-- 立即支付-->
		<view class="payment">
			<view class="total-price">
				<text>共{{totalCount}}件,</text>
				待支付：<text class="pub">{{totalPrice}}</text>
			</view>
			<view class="btn-buy" @click="onPayment(newCartList)">
				立即购买
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {

			}
		},
		mounted() {
			console.log(this.cartList);
		},
		computed: {
			...mapState({
				cartList: state => state.cart.cartList
			}),
			...mapGetters(['totalPrice', 'totalCount', 'newCartList'])
		},
		methods: {
			...mapMutations(['delShopList', 'changeOrderListMutation']),
			// 添加或删除商品数量
			onChange(isAdd, index) {
				this.delShopList({
					isAdd,
					index
				})
			},
			// 支付
			onPayment() {
				// this.newCartList =[]
				// this.changeOrderListMutation(newCartList)
			}
		}
	}
</script>

<style lang="scss">
	.order-container {
		width: 100vw;
		height: 100vh;
		font-size: 28rpx;
		background: #f4f4f4;
		box-sizing: border-box;

		.person-info {
			margin: 20rpx;
			padding: 0 20rpx;
			height: 200rpx;
			border-radius: 20rpx;
			background: #fff;

		}

		.shop-list {
			margin: 20rpx;
			padding: 0 20rpx;
			border-radius: 20rpx;
			background: #fff;

			.cart-item {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;

				.shop-img {
					width: 200rpx;
					height: 200rpx;
				}

				.shop-info {
					flex: 1;
					margin: 0 10rpx;

					.price {
						margin: 20rpx 0;

						&::before {
							content: '¥';
							display: inline-block;
							font-size: 24rpx;
						}
					}

					.number {
						text-align: right;

						.del,
						.add,
							{
							display: inline-block;
							width: 50rpx;
							height: 50rpx;
							line-height: 50rpx;
							text-align: center;
							border: 1rpx solid #ccc;
							background: #f8f8f8;
						}

						.count {
							display: inline-block;
							width: 80rpx;
							height: 50rpx;
							line-height: 50rpx;
							text-align: center;
							border-top: 1rpx solid #ccc;
							border-bottom: 1rpx solid #ccc;
						}
					}

				}
			}

		}

		.shop-info {
			margin: 20rpx;
			padding: 15rpx 20rpx;
			border-radius: 20rpx;
			background: #fff;

			.common {
				display: flex;
				justify-content: space-between;
				height: 70rpx;
				line-height: 70rpx;

				.all-price {
					color: #000;
					&::before{
						content: '¥';
						display: inline-block;
						font-size: 24rpx;
					}
				}

				.pub {
					color: #b5abab;
				}
			}
		}

		.order-comment {
			display: flex;
			justify-content: space-between;
			margin: 20rpx;
			padding: 0 20rpx;
			height: 100rpx;
			line-height: 100rpx;
			border-radius: 20rpx;
			background: #fff;
		}

		.payment {
			display: flex;
			align-items: center;
			position: fixed;
			left: 0;
			bottom: 0;
			width: 100vw;
			height: 100rpx;
			background: #fff;

			.total-price {
				flex: 1;
				text-align: right;


				.pub {
					color: #e20909;
					font-size: 38rpx;
					font-weight: bold;
					&::before{
						content: '¥';
						display: inline-block;
						font-size: 24rpx;
					}
				}
			}

			.btn-buy {
				margin: 0 20rpx;
				width: 200rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				font-size: 24rpx;
				letter-spacing: 3rpx;
				border-radius: 999rpx;
				color: #fff;
				background-color: #fd7402;
			}
		}
	}
</style>
